"""
encoding = 'utf-8'
@author : ffine
@time   : 2022-04-30  21:09
@IDEA   : PyCharm
@goal   : 枚举解决:1.可读性 2.防止修改 3.防止重复
"""
# 防篡改
from enum import Enum, unique

# 可被修改的变量
"""
COLORS = {"red"  : 1,
          "green": 2,
          "white": 3,
          "black": 4, }
color = 3
if color == COLORS["red"]:
	print("red")
elif color == COLORS["green"]:
	print("green")
elif color == COLORS["white"]:
	print("white")
elif color == COLORS["black"]:
	print("black")
else:
	print("error")
"""


class Color(Enum):
	red = 1
	red1 = 1
	green = 2
	green1 = 2
	white = 3
	black = 4


color = 4

if color == Color.red.value:
	print("red")
elif color == Color.green.value:
	print("green")
elif color == Color.white.value:
	print("white")
elif color == Color.black.value:
	print("black")
else:
	print("error")

print(Color["red"])
print(Color["red"].value)
print(Color(1))

print("===========================")
for c in Color:
	print(c)
	print(c.value)
	print(c.name)

print("===========================")
for c in Color.__members__:
	print(c)
	print(Color[c].name + ":" + str(Color[c].value))

print("===========================")


# 防止重复
@unique
class Color1(Enum):
	red = 1
	# red1 = 1,不能重复
	green = 2
	white = 3
	black = 4
